package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import cn.hutool.db.meta.Table;
import com.ruoyi.system.domain.vo.carportSellinfo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TCarportsell;
import com.ruoyi.system.service.ITCarportsellService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 车位销售Controller
 * 
 * @author ruoyi
 * @date 2022-11-29
 */
@RestController
@RequestMapping("/system/carportsell")
public class TCarportsellController extends BaseController
{
    @Autowired
    private ITCarportsellService tCarportsellService;

    @GetMapping("/getcarportSellinfo")
    public TableDataInfo getcarportSellinfo(carportSellinfo carportSellinfo){
        startPage();
        List<carportSellinfo> carportSellInfo = tCarportsellService.getCarportSellInfo(carportSellinfo);
        return getDataTable(carportSellInfo);
    }
    
    /**
     * 查询车位销售列表
     */
    @PreAuthorize("@ss.hasPermi('system:carportsell:list')")
    @GetMapping("/list")
    public TableDataInfo list(TCarportsell tCarportsell)
    {
        startPage();
        List<TCarportsell> list = tCarportsellService.selectTCarportsellList(tCarportsell);
        return getDataTable(list);
    }

    /**
     * 导出车位销售列表
     */
    @PreAuthorize("@ss.hasPermi('system:carportsell:export')")
    @Log(title = "车位销售", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TCarportsell tCarportsell)
    {
        List<TCarportsell> list = tCarportsellService.selectTCarportsellList(tCarportsell);
        ExcelUtil<TCarportsell> util = new ExcelUtil<TCarportsell>(TCarportsell.class);
        util.exportExcel(response, list, "车位销售数据");
    }

    /**
     * 获取车位销售详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:carportsell:query')")
    @GetMapping(value = "/{sellid}")
    public AjaxResult getInfo(@PathVariable("sellid") Long sellid)
    {
        return success(tCarportsellService.selectTCarportsellBySellid(sellid));
    }

    /**
     * 新增车位销售
     */
    @PreAuthorize("@ss.hasPermi('system:carportsell:add')")
    @Log(title = "车位销售", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TCarportsell tCarportsell)
    {
        return toAjax(tCarportsellService.insertTCarportsell(tCarportsell));
    }

    /**
     * 修改车位销售
     */
    @PreAuthorize("@ss.hasPermi('system:carportsell:edit')")
    @Log(title = "车位销售", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TCarportsell tCarportsell)
    {
        return toAjax(tCarportsellService.updateTCarportsell(tCarportsell));
    }

    /**
     * 删除车位销售
     */
    @PreAuthorize("@ss.hasPermi('system:carportsell:remove')")
    @Log(title = "车位销售", businessType = BusinessType.DELETE)
	@DeleteMapping("/{sellids}")
    public AjaxResult remove(@PathVariable Long[] sellids)
    {
        return toAjax(tCarportsellService.deleteTCarportsellBySellids(sellids));
    }
}
